package com.dly.hope.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;

import java.util.Properties;

/**
 * @author linyu.dai
 * @project myserve
 * @description 邮件配置类
 * @creat 2022/8/28 10:58:34
 */
@Configuration
public class EmailConfig {

    @Bean
    public JavaMailSender javaMailSender(){
        JavaMailSenderImpl javaMailSender = new JavaMailSenderImpl();
        javaMailSender.setHost("smtp.163.com"); //SMTP服务器地址
        javaMailSender.setUsername("learnerdly@163.com"); //设置登入账号
        javaMailSender.setPassword("YYEKGEYXWGBSUMKI"); //授权码

        Properties properties = new Properties();
        properties.setProperty("mail.smtp.timeout", "25000");
        properties.setProperty("mail.from", "learnerdly@163.com"); //设置发件人
        properties.setProperty("mail.smtp.socketFactory.port", "465");

        return javaMailSender;
    }
}
